package com.dorm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dorm.entity.Repair;
import com.dorm.mapper.RepairMapper;
import com.dorm.service.RepairService;
import org.springframework.stereotype.Service;

/**
 * 报修服务实现类
 */
@Service
public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> implements RepairService {

    @Override
    public Page<Repair> pageQuery(Integer pageNum, Integer pageSize, String status, Long studentId) {
        Page<Repair> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<Repair> wrapper = new LambdaQueryWrapper<>();
        
        if (status != null && !status.isEmpty()) {
            wrapper.eq(Repair::getStatus, status);
        }
        if (studentId != null) {
            wrapper.eq(Repair::getStudentId, studentId);
        }
        
        wrapper.orderByDesc(Repair::getCreateTime);
        return page(page, wrapper);
    }
}

